use barcoders::sym::code39::*;
use barcoders::sym::code128::*;
use barcoders::generators::image::*;
use std::io::prelude::*;
use std::io::BufWriter;
use std::fs::File;
use std::path::Path;
// use text_to_png::TextRenderer;

pub fn main(){
    let barcode = Code39::new("1ISTHELONELIESTNUMBER").unwrap();
    let png = Image::png(80); // You must specify the height in pixels.
    let encoded = barcode.encode();
    
    // Image generators return a Result<Vec<u8>, barcoders::error::Error) of encoded bytes.
    let bytes = png.generate(&encoded[..]).unwrap();
    
    // Which you can then save to disk.
    let file = File::create(&Path::new("my_barcode.png")).unwrap();
    let mut writer = BufWriter::new(file);
    writer.write(&bytes[..]).unwrap();

    let s123 =  Code128::new("ÀWOSHIZ").unwrap();
    let s123_encode = s123.encode();
    let png1 = Image::png(80);
      // Image generators return a Result<Vec<u8>, barcoders::error::Error) of encoded bytes.
      let bytes = png1.generate(&s123_encode[..]).unwrap();
    
      // Which you can then save to disk.
      let file = File::create(&Path::new("my_barcode1.png")).unwrap();
      let mut writer = BufWriter::new(file);
      writer.write(&bytes[..]).unwrap();

    //   let renderer = TextRenderer::default();

// let text_png = renderer.render_text_to_png_data(
//     "Rénder this, brö",
//     64,
//     "Dark Turquoise").unwrap();

}
